package cn.kailangtu.myapplication;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.SystemClock;
import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Locale;

import cn.kailangtu.myapplication.data.Address;
import cn.kailangtu.myapplication.data.MainData;
import cn.kailangtu.myapplication.services.SerialDataService;
import cn.kailangtu.myapplication.tools.APPSPUtils;
import cn.kailangtu.myapplication.tools.AdbUtil;
import cn.kailangtu.myapplication.tools.CrashHandler;
import cn.kailangtu.myapplication.tools.MediaPlayerUtils;

public class MyApplication extends Application {

//声音播放插件
    public static Context ApplicationContext;

    @Override
    public void onCreate() {

        super.onCreate();
        //声音播放
        MyApplication.ApplicationContext = this;

        APPSPUtils.getInstance().init(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            startForegroundService(new Intent(this, SerialDataService.class));
        } else {

            startService(new Intent(this, SerialDataService.class));
        }

        //MainData.Test();


        SimpleDateFormat format =  new SimpleDateFormat("MMddHHmmyyyy.ss", Locale.getDefault());
        String timeStr = format.format(System.currentTimeMillis() - 1000 * 60 * 60 *24 * 500);
        Log.d("TIMETIMETIME",timeStr);
        AdbUtil.run("date '"+timeStr+"'");


        CrashHandler.active(this);

       // Address.getInstance().testAll();
    }
}
